package lex.util;

import javax.swing.AbstractButton;

/**
 * The order of evaluation of the states is: 1. Test if button is disabled 2.
 * Test if button is pressed 3. Test if button is in rollover state 4. Button
 * must be in normal state then.
 */
public class ButtonState {
	public static final int normal = 0;
	public static final int rollover = 1;
	public static final int pressed = 2;
	public static final int disabled = 4;

	public static int getState(AbstractButton button) {
		if (!button.isEnabled())
			return disabled;
		if (button.getModel().isPressed()) // Do we need to check for armed ??
			return pressed;
		if (button.getModel().isRollover())
			return rollover;
		return normal;
	}
}
